package com.hngy.java.tablesql;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.api.bridge.java.BatchTableEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * 创建TableEnvironment对象
 */
public class CreateTableEnvironmentJava {

    public static void main(String[] args) {
        //创建TableEnvironment对象-stream
        EnvironmentSettings sSetting = EnvironmentSettings.newInstance().inStreamingMode().build();
        TableEnvironment sTableEnv = TableEnvironment.create(sSetting);

        //创建TableEnvironment对象-batch
        EnvironmentSettings bSetting = EnvironmentSettings.newInstance().inBatchMode().build();
        TableEnvironment bTableEnv = TableEnvironment.create(bSetting);

        //创建StreamTableEnvironment
        StreamExecutionEnvironment ssEnv = StreamExecutionEnvironment.getExecutionEnvironment();
        EnvironmentSettings ssSetting = EnvironmentSettings.newInstance().inStreamingMode().build();
        StreamTableEnvironment ssTableEnv = StreamTableEnvironment.create(ssEnv, ssSetting);

        //创建BatchTableEnvironment
        //注意：此时只能使用旧的执行引擎，新的Blink执行引擎不支持和DataSet转换
        ExecutionEnvironment bbEnv = ExecutionEnvironment.getExecutionEnvironment();
        BatchTableEnvironment bbTableEnv = BatchTableEnvironment.create(bbEnv);
    }
}
